# Contributor: Maxim Karasev <begs@disroot.org>
# Maintainer: Maxim Karasev <begs@disroot.org>
pkgname=zapret
pkgver=0.0.0_git20220125
_commit=9a7d1e8e56ef20903e2a39da5d627a5a60c2cbf2
pkgrel=0
pkgdesc="autonomous deep packet inspection circumvention toolkit"
url="https://github.com/bol-van/zapret"
arch="all"
license="MIT"
depends="ipset bind-tools"
makedepends="zlib-dev libcap-dev libnetfilter_queue-dev bsd-compat-headers"
depends_openrc="iptables ip6tables"
install="$pkgname.pre-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://github.com/bol-van/zapret/archive/$_commit/zapret-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	"
builddir="$srcdir/$pkgname-$_commit"
options="!check" # no tests

build() {
	make TGT=binaries/alpine
}

package() {
	install -Dm755 binaries/alpine/nfqws binaries/alpine/tpws \
		-t "$pkgdir"/usr/bin

	install -Dm644 "$srcdir"/zapret.confd "$pkgdir"/etc/conf.d/zapret
	install -Dm755 "$srcdir"/zapret.initd "$pkgdir"/etc/init.d/zapret

	install -Dm644 config "$pkgdir"/usr/share/"$pkgname"/config
	cp -r ipset "$pkgdir"/usr/share/"$pkgname"
	mkdir -p "$pkgdir"/usr/share/"$pkgname"/init.d
	cp -r init.d/sysv "$pkgdir"/usr/share/"$pkgname"/init.d

	mkdir -p "$pkgdir"/usr/share/doc/"$pkgname"
	cp -r docs/* "$pkgdir"/usr/share/doc/"$pkgname"
	mkdir -p "$pkgdir"/usr/share/licenses/"$pkgname"
	mv "$pkgdir"/usr/share/doc/"$pkgname"/LICENSE.txt "$pkgdir"/usr/share/licenses/"$pkgname"
}

sha512sums="
49c3bad3cbbd79400c3748392c6ab4cb542c2a4a3e7307697bc3670ecc9ed15e45fd20aea7a3322ed303d33372943e4b97a3e792c149e3aefd964d36f5c6824e  zapret-0.0.0_git20220125.tar.gz
6582053bc83fec3609233fb06f3ae88ef1257fc52c3d8699473f6593b2a45d458401d2f70f25306fedd8718776a3e09077113cf79917be1c99bfa3f56a63a16d  zapret.initd
962b18fe57ddd20d870f91a7de7f7b6b108602ec94553d4efc1372cf247d95ca472043d490f16e9c5e83f3aa78ae09fcd3028df49d497c0f76292782981111e1  zapret.confd
"
